home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / WINDOWS / LZAPI.ZIP / TPW.ZIP / LZAPI.PAS next >
Encoding:
Pascal/Delphi Source File  |  1996-09-06  |  11.9 KB  |  281 lines

  1. {-----------------------------------------------------------------------*
  2.  *                                                                      *
  3.  *            L Z A P I . P A S                     *
  4.  *                                    *
  5.  * Include File for LZW-Archiver/Unarchiver-DLLs included in the LZAPI  *
  6.  * DLL-System                                *
  7.  * (C) 1996                                                             *
  8.  *    Dipl. Ing. Bernd Herd                                           *
  9.  *    Rodulf-Virchow-Str. 8                                           *
  10.  *    68742 BBⁿrstadt                                                 *
  11.  *    Tel. 06206/79222                                                *
  12.  *      EMail: herdsoft@aol.com                                         *
  13.  *----------------------------------------------------------------------}
  14.  
  15. Unit LZApi;
  16. Interface
  17.  
  18. uses WinTypes;
  19.  
  20. {$IFDEF WIN32}
  21. const LZAPI_DLL_NAME = 'LZAPI32.DLL';
  22. {$ELSE}
  23. const LZAPI_DLL_NAME = 'LZAPI';
  24. {$ENDIF}
  25.  
  26. { Purpose of LZAPI:
  27.    Included in the LZAPI-Package are several Packer/Unpacker-DLLs:
  28.    WLHA.DLL        LZH Unpacker/Packer
  29.    WZIP.DLL             ZIP Packer
  30.    WUNZIP.DLL        ZIP Unpacker
  31.    WARC.DLL        ARC Unpacker/Packer
  32.    WUNARJ.DLL        ARJ Unpacker
  33.  
  34.    LZAPI is a Common API-Definition for all this packers that make them
  35.    all the same in the Calling Convention Usage.
  36.  
  37.    Each packer DLL has it's own more powerfull API Functionality, but
  38.    for LZAPI all of them support at least:
  39.  
  40.    XXXList(LPLACTL)    : Copy a Listing of the Archives Contents into
  41.               a Specified Memory Block
  42.  
  43.    XXXExtract(LPLACTL)    : Extract one or more Files
  44.  
  45.    XXXDelete(LPLACTL)   : Delete one or more Files
  46.  
  47.    XXXAppend(LPLACTL)   : Append one or more Files
  48.  
  49.    XXX is a Placeholder for the Archiv-Type, that Means LZH/ZIP/ARJ/ARC
  50.  
  51.    The LZAPI.DLL will add to this Functionality the Automatic determination, wich
  52.    Library will actually needed to analyze a given File, which is especially
  53.    interesting with Self-Extracting Archives. It will also look if the DLL
  54.    currently wantet is in fact Available.
  55.  
  56.    All the Informations are exchanged with the help of an Control-Block
  57.    Structure, because it makes Dynamic Linking via "LoadLibrary" much easier.
  58.  
  59. }
  60.  
  61.  
  62. {  ----------- Error Codes Definition -------------------- }
  63. type   LAERR = Integer;
  64.  
  65. const  LAE_OK=             0;        {  No Error occured }
  66. const  LAE_ARCHIVNOTFOUND=      2020;        {  Archiv File not Found }
  67. const  LAE_BROKEN=              2021;        {  Broken Archiv }
  68. const  LAE_INSTANCE=         2026;           {  Instanz-Handling-Error (i.e. tried to run more than one Process) }
  69. const  LAE_INFILENOTFOUND=      2027;           {  Input File not found }
  70. const  LAE_STOPPED=             2028;           {  Stopped by Callbac-Routine }
  71. const  LAE_WRONGTYPE=           2029;        {  Wrong Type of File }
  72. const  LAE_DLLMISSING=         2030;        {  Dll missing or errornous }
  73. const  LAE_DOSBOX=        2051;        {  Problem while executine a DOS-Box occured }
  74. const  LAE_TEMPORARY=           2041;           {  Error deleting or renaming temporary File }
  75. const  LAE_PARAMETERS=        2053;        {  Illegal Parameters (i.e. lpstrListing NULL during LAList) }
  76. const  LAE_MEM=            2054;        {  Virtual memory exhausted }
  77. const  LAE_WRITE=        2055;        {  Error while creating or writing destination File. }
  78.  
  79. {  ----------- Flag-Value Definitions -------------------- }
  80. const  LAF_SHORTNAMES=        $200;        {  Recommended Option to Supress usage of Long Filenames }
  81. const  LAF_ALLOWGROWEXIST=    $400;        {  Allow existing Archiv to Grow on Add (Supported by WZIP only)
  82.                            This Reduces Copying so things become faster.    
  83.                         }
  84.  
  85. { ------- Archiver-Type Constants ------------------------ }
  86. { Return values for "LAIsArchiv" and "ArchiverType"-Field of LACTL-Structure }
  87. const TY_NONE =0;
  88. const TY_LZH  =1;
  89. const TY_ARC  =2;
  90. const TY_ARJ  =3;
  91. const TY_ZIP  =4;
  92. const TY_RAR  =5;
  93. const TY_TAR  =6;
  94. const TY_ZOO  =7;
  95.  
  96. {  ----------- Define Control Structure ------------------ }
  97. type  LPLACTL = ^LACTL;
  98.         TCallback = Function(Msg : Integer; Ctl : LPLACTL) : Integer
  99.                   {$IFDEF WIN32} stdcall {$ENDIF}
  100.                   ;
  101.  
  102.     LACTL = RECORD
  103.              lStructSize : LongInt;     {  Length of the Control Structure in Bytes }
  104.              hwndOwner   : hWnd;        {  Handle of the Parent Window (Needed for Message-Boxes etc.) }
  105.              lpstrArchivFile : PChar;   {  Points to a Buffer that specifies the Name of the Archiv File }
  106.              lpstrWildCards  : PChar;   {  Points to a Buffer that specifies the File-Names to be listet or }
  107.                         {  Extracted, like "*.*" or "*.DOC", or NULL for ANY FILE }
  108.              lpstrPath       : Pchar;    {  Points to a Buffer that specifies the destination Pathname }
  109.                         {  for the extracted Files (for Example C:\\TMP) }
  110.              Flags           : LongInt; {  Some LA_xxxx - Flags, combined via or - Operator }
  111.  
  112.                      lpfnCallback    : TCallback;{  Pointer to Callback-Routine to support "Multitasking". }
  113.  
  114.     {  -------- Listing-Function only ------------------------ }
  115.              lpstrListing    : PChar;   {  Points to a Buffer that shall receive the Directory Listing }
  116.  
  117.     {  -------- Application-Reserved Fields ------------------ }
  118.              lParam         : LongInt; {  These Fields may be used freely by the application Program }
  119.              lpVoid         : Pointer;
  120.              iCounter         : SmallInt;
  121.  
  122.     { --------- New in Version 1.3 --------------------------- }
  123.              ArchiverType    : SmallInt;    { TY_xxxx - Value to select an Archiver (TY_NONE for auto-Selection) }
  124.  
  125.     { -------- New in Version 2.0 ---------------------------  }
  126.                  lpstrProcessedFile : PChar;{ File that is currently processed inside of the Archiv }
  127.                  uPercentOfFile     : Cardinal;    { Percentage of file processed at LAM_PERCENTOFFILE - Message }
  128.              uPercentOfArchiv   : Cardinal;    { Percentage of file processed at LAM_NEXTFILE      - Message }
  129.              Reserved           : Array[1..10] of LongInt; { Reserved for future use, must be all zero }
  130.  
  131.  
  132.     end;
  133.  
  134. {  ----------- Display an Error-Message ------------------ }
  135. procedure LAErrMsg( errId : LAErr; Ctl : LPLACTL); far;
  136.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  137.  
  138. {  ----------- Callback-Procedure template --------------- }
  139. { typedef LAERR (CALLBACK* LACALLBACK)(int, LPLACTL);    {  Type declaration Callback-Function }
  140.  
  141. { ----------- Callback Routine Messages ------------------------------ }
  142. const  LAM_PEEK=           1;             {  Nothing special }
  143. const  LAM_NEXTFILE=       2;             {  Start processing next File
  144.                                              (Only handled by SOME Archivers)  }
  145. const  LAM_PERCENTOFFILE=  3;          {  Transfer of %-Value of file processed in Archiv
  146.                                              (Only handled by SOME Archivers) }
  147. const  LAM_MAPNAME=       4;          {  Allow to change name of File
  148.                                              (in lpstrProcessedFile) before unzipping (WUNZIP.DLL) }
  149.  
  150. { ------------- Callback-Notification-Codes ----- }
  151. const  LAN_OK=                    0;              {  Nothing special }
  152. const  LAN_STOP=                  2;              {  Used with LHAM_PEEK     : Stop Decompression of Archive immediatly }
  153.  
  154.  
  155. {  ------------ Archive-Type independend Versions -------- }
  156. function LAList(    lpCtl : LPLACTL) : LAERR; far;
  157.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  158. function LAExtract( lpCtl : LPLACTL) : LAERR; far;
  159.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  160. function LAAppend(  lpCtl : LPLACTL) : LAERR; far;
  161.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  162. function LADelete(  lpCtl : LPLACTL) : LAERR; far;
  163.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  164.  
  165. {  ------------- Direct Parameter Versions --------------- }
  166.  
  167. function LAListDirect( hwndOwner : HWnd;
  168.                        ArchivFile: PChar;
  169.                        Wildcards : PChar;
  170.                        Listing   : PChar;
  171.                        Flags     : LongInt;
  172.                        Callback  : Pointer)  : LAERR; far;
  173.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  174.  
  175. function LAExtractDirect( hwndOwner : HWnd;
  176.                           ArchivFile: PChar;
  177.                           DestPath  : PChar;
  178.                           Wildcards : PChar;
  179.                           Flags     : LongInt;
  180.                           Callback  : Pointer) : LAERR; far;
  181.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  182.  
  183. function LAAppendDirect(  hwndOwner : HWnd;
  184.                           ArchivFile: PChar;
  185.                           SourcePath: PChar;
  186.                           Wildcards : PChar;
  187.                           Flags     : LongInt;
  188.                           Callback  : Pointer) : LAERR; far;
  189.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  190.  
  191. function LADeleteDirect(  hwndOwner : HWnd;
  192.                           ArchivFile: PChar;
  193.                           Wildcards : PChar;
  194.                           Flags     : LongInt;
  195.                           Callback  : Pointer) : LAERR; far;
  196.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  197.  
  198.  
  199.  
  200. { -------------- Support Functions ---------------------- }
  201. function LAGetExtensionString(Compress : Boolean) : Pchar; far;
  202.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  203.     { Retrieves a String-Pointer to the List of
  204.       Currently supported extenstions "*.LZH;*.ARJ;*.ZIP;*.ARC" etc. }
  205.  
  206. function LAIsArchiv(FileName : PChar) : Integer; far;
  207.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  208.     { Test if the FileName given marks an Archiv that may be
  209.       listed or decompressed }
  210.  
  211.  
  212. { -------------- Shareware Registration -----------------}
  213. function LARegister(lpszUserName : PChar; lpszPassword : PChar) : Boolean; far;
  214.                   {$IFDEF WIN32} stdcall; {$ENDIF}
  215.  
  216.  
  217.  
  218. implementation
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226. {  ----------- Display an Error-Message ------------------ }
  227. procedure LAErrMsg( errId : LAErr; Ctl : LPLACTL); external LZAPI_DLL_NAME;
  228.  
  229.  
  230.  
  231.  
  232. {  ------------ Archive-Type independend Versions -------- }
  233. function LAList(    lpCtl : LPLACTL) : LAERR; external LZAPI_DLL_NAME;
  234. function LAExtract( lpCtl : LPLACTL) : LAERR; external LZAPI_DLL_NAME;
  235. function LAAppend(  lpCtl : LPLACTL) : LAERR; external LZAPI_DLL_NAME; 
  236. function LADelete(  lpCtl : LPLACTL) : LAERR; external LZAPI_DLL_NAME;
  237.  
  238. {  ------------- Direct Parameter Versions --------------- }
  239.  
  240. function LAListDirect( hwndOwner : HWnd;
  241.                        ArchivFile: PChar;
  242.                        Wildcards : PChar;
  243.                        Listing   : PChar;
  244.                        Flags     : LongInt;
  245.                        Callback  : Pointer)  : LAERR; external LZAPI_DLL_NAME;
  246.  
  247. function LAExtractDirect( hwndOwner : HWnd;
  248.                           ArchivFile: PChar;
  249.                           DestPath  : PChar;
  250.                           Wildcards : PChar;
  251.                           Flags     : LongInt;
  252.                           Callback  : Pointer) : LAERR; external LZAPI_DLL_NAME;
  253.  
  254. function LAAppendDirect(  hwndOwner : HWnd;
  255.                           ArchivFile: PChar;
  256.                           SourcePath: PChar;
  257.                           Wildcards : PChar;
  258.                           Flags     : LongInt;
  259.                           Callback  : Pointer) : LAERR; external LZAPI_DLL_NAME;
  260.  
  261. function LADeleteDirect(  hwndOwner : HWnd;
  262.                           ArchivFile: PChar;
  263.                           Wildcards : PChar;
  264.                           Flags     : LongInt;
  265.                           Callback  : Pointer) : LAERR; external LZAPI_DLL_NAME;
  266.  
  267. { -------------- Support Functions ---------------------- }
  268. function LAGetExtensionString(Compress : Boolean) : Pchar; external LZAPI_DLL_NAME;
  269.     { Retrieves a String-Pointer to the List of
  270.       Currently supported extenstions "*.LZH;*.ARJ;*.ZIP;*.ARC" etc. }
  271.  
  272. function LAIsArchiv(FileName : PChar) : Integer; external LZAPI_DLL_NAME;
  273.     { Test if the FileName given marks an Archiv that may be
  274.       listed or decompressed }
  275.  
  276.  
  277. { -------------- Shareware Registration -----------------}
  278. function LARegister(lpszUserName : PChar; lpszPassword : PChar) : Boolean; external LZAPI_DLL_NAME;
  279.  
  280. End.
  281.